# = Class SymTable
# Implementation of the Symbols Table for the programming language Vectorinox
class SymTable
  
  # Hash table that represents the symbols table
  attr_reader :table
  
  # Constructor for the class
  # === Parameters
  # none
  def initialize
    @table = Hash.new
  end

  def merge_table sym_table
    @table = @table.merge sym_table.table
  end

  # Method used to insert a new element into the symbols table
  # === Parameters
  # * s: Sym that contains the symbol that wants to be inserted into the symbols table
  def insert s
    @table[s.name.downcase] = s
  end

  # Method used to locate a particular symbol in the table
  # === Parameters
  # * n: String containing the name of the symbol that wants to be located
  def find n
    @table[n.downcase]
  end
  
  
  # Method used to delete a particular symbol in the table
  # === Parameters
  # * n: String containing the name of the symbol that wants to be deleted
  def delete n
    @table.delete(n)
  end
  
  # Creates a 'String' representation of the Symbols Table with 'i' identation spaces
  # === Parameters
  # * i: Identation with which the Symbols Table should be printed with
 def to_s i
    output = ''
    @table.each {|key, value|
      output += "\n#{i}#{key}: #{value.type}"
    }
    output
  end
end